<?php
namespace app\Model\Wechat;

class Container
{
    public $values = [];

    public function __construct()
    {
        $this->registerProviders();
    }

    public function registerProviders()
    {
        foreach (static::$providers as $provider){

            $provider::register($this);
        }

        return $this;
    }

    public function __get($name)
    {
        if(!isset($this->values[$name])){
            throw new \Exception('该服务不存在');
        }

        return $this->values[$name]();
    }
}